package com.sbs.gaoxinqutoilet.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.lcodecore.tkrefreshlayout.IBottomView;
import com.lcodecore.tkrefreshlayout.utils.DensityUtil;
import com.sbs.gaoxinqutoilet.R;

/**
 * Created by 聪明一只哈 on 2020/5/6.
 * Time: 2020/5/6  11:35
 */
public class LoadBottomView extends LinearLayout implements IBottomView {

    private ImageView refreshArrow;
    private TextView refreshTextView;
    private ImageView loadingView;

    public LoadBottomView(Context context) {
        this(context,null);
    }

    public LoadBottomView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs,0);
    }

    public LoadBottomView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        int size = DensityUtil.dp2px(context,15);
//        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(size,size);
//        params.gravity = Gravity.CENTER_HORIZONTAL;
//        setLayoutParams(params);
//        setImageResource(R.drawable.anim_loading_view);

        //init();
        View rootView=LayoutInflater.from(context).inflate(R.layout.loading_bottom,this,false);
        //View rootView = View.inflate(getContext(), R.layout.loading_bottom, null);
        addView(rootView);

    }

    private void init() {
        View rootView = View.inflate(getContext(), R.layout.loading_bottom, null);
        refreshArrow = (ImageView) rootView.findViewById(R.id.iv_arrow);
        refreshTextView = (TextView) rootView.findViewById(R.id.tv);
        loadingView = (ImageView) rootView.findViewById(R.id.iv_loading);
        addView(rootView);
    }


    @Override
    public View getView() {
        return this;
    }

    @Override
    public void onPullingUp(float fraction, float maxBottomHeight, float bottomHeight) {

    }

    @Override
    public void startAnim(float maxBottomHeight, float bottomHeight) {
        //((AnimationDrawable)getDrawable()).start();
    }

    @Override
    public void onPullReleasing(float fraction, float maxBottomHeight, float bottomHeight) {

    }

    @Override
    public void onFinish() {

    }

    @Override
    public void reset() {

    }
}
